import axios from "axios";
import { requestHandle, requestExceptionHandle, responseHandle, responseExceptionHandle } from "./interceptors";

const config = {
  baseURL: import.meta.env.VITE_APP_APIURL,
  timeout: 10000,
  headers: {
    "content-type": "application/json",
  },
};

const http = axios.create(config);

http.interceptors.request.use(
  (...args) => requestHandle(http, ...args),
  (...args) => requestExceptionHandle(http, ...args)
);

http.interceptors.response.use(
  (...args) => responseHandle(http, ...args),
  (...args) => responseExceptionHandle(http, ...args)
);

export default http;
